<html>
<head>
  <title>Evernote Export</title>
  <basefont face="微软雅黑" size="2" />
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  <meta name="exporter-version" content="YXBJ Windows/601568 (zh-CN, DDL); Windows/10.0.0 (Win64); EDAMVersion=V2;"/>
  <style>
    body, td {
      font-family: 微软雅黑;
      font-size: 10pt;
    }
  </style>
</head>
<body>
<a name="555"/>
<h1>01-JS基础</h1>
<div>
<table bgcolor="#D4DDE5" border="0">
<tr><td><b>创建时间：</b></td><td><i>2018/4/2 19:15</i></td></tr>
<tr><td><b>更新时间：</b></td><td><i>2020/3/29 12:27</i></td></tr>
<tr><td><b>作者：</b></td><td><i>18081003141@163.com</i></td></tr>
</table>
</div>
<br/>

<div>
<span><div><div><div><font style="font-size: 18pt;"><span style="font-size: 18pt;">1.Javascript是一门</span><span style="font-size: 18pt; font-weight: bold;">面向对象</span><span style="font-size: 18pt;">的，</span><span style="font-size: 18pt; font-weight: bold;">跨平台</span><span style="font-size: 18pt;">的</span><span style="font-size: 18pt; font-weight: bold;">脚本</span><span style="font-size: 18pt;">语言 </span></font></div><div><span style="font-size: 14pt; color: rgb(255, 70, 53);">什么是面向对象？</span></div><div><span style="font-size: 14pt; color: rgb(255, 70, 53);">对象：属性和方法</span></div><div><br/></div><div><img src="00-笔记_files/你办事我放心.png" type="image/png" data-filename="你办事我放心.png" width="628"/></div><div><br/></div><div><br/></div><div><span style="font-size: 14pt; color: rgb(255, 0, 0);">什么是跨平台？</span></div><div><br/></div><div><img src="00-笔记_files/Image.png" type="image/png" data-filename="Image.png" width="634"/></div><div><br/></div><div><span style="font-size: 14pt; color: rgb(255, 0, 0);">什么是脚本语言？</span></div><div><br/></div><div><img src="00-笔记_files/Image [1].png" type="image/png" data-filename="Image.png"/></div><div><br/></div><div><br/></div><div><span style="font-size: 12pt; font-family: &quot;Microsoft JhengHei&quot;;">HTML文件必须在浏览器里执行。</span></div><div><span style="font-size: 12pt; font-family: &quot;Microsoft JhengHei&quot;;">JS文件嵌入到HTML文件里才能执行。</span></div><div><span style="font-size: 12pt; background-color: rgb(255, 250, 165); font-family: &quot;Microsoft JhengHei&quot;;-evernote-highlight:true;">凡是不能独立执行需要依赖其他程序的，通常都叫做脚本，也叫动态语言。（宿主语言）</span></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 18pt;">2.JS历史</span></div><div><br/></div><div><span style="font-size: 12pt;">早期的浏览器一般用来浏览文字信息，比如查看新闻时事，也可以做一些登陆注册之类的操作，</span><span style="font-size: 12pt;">但是不具备程序处理能力，所有的业务都是在服务器完成，而网络带宽又很小，往往一些简单的操作会花费大量时间，这个时候就希望浏览器也能处理一些简单的逻辑，比如数据验证。</span></div><div><span style="font-size: 14pt;"><br/></span></div><div><span style="font-size: 14pt;"><br/></span></div><div><span style="font-size: 14pt;">早期的</span><span style="font-size: 14pt; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248); color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;">浏览器</span></div><div><br/></div><div><img src="00-笔记_files/Netscape Navigator.jpg" type="image/jpeg" data-filename="Netscape Navigator.jpg"/></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt;">1</span><span style="font-size: 12pt;">995 </span> <span style="font-size: 12pt;"> </span> <span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">最初由</span><a href="https://baike.baidu.com/item/Netscape" style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;">Netscape</a><span style="font-size: 12pt;">（网景公司）</span><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">的</span><a href="https://baike.baidu.com/item/Brendan%20Eich" style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;">Brendan Eich</a><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">设计</span><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: arial, 宋体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">   </span><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: arial; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="font-size: 12pt; color: rgb(51, 51, 51); font-variant-caps: normal; font-variant-ligatures: normal;">为<span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;">Netscape Navigator 2.0开发</span></span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;">LiveScript</span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;"> </span></span></div><div><br/></div><div><span style="font-size: 12pt;"><img src="00-笔记_files/Brendan Eich.png" type="image/png" data-filename="Brendan Eich.png" width="214"/></span></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><span style="background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;">就在 Netscape Navigator 2.0 即将正式发布前，Netscape 将其更名为 JavaScript</span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><span style="background-color: rgb(253, 252, 248); font-size: 12pt;"><br/></span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">因为Netscape</span><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">与Sun</span><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">合作，</span><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">Netscape</span><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">管理层希望它外观看起来像</span><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">Java</span><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">，因此取名为JavaScript</span></div><div><br/></div><div><br/></div><div><font style="font-size: 14pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 14pt; font-variant-caps: normal; font-variant-ligatures: normal;">那JavaScript跟Java有什么关系呢？</span></font></div><div><br/></div><div><font style="font-size: 12pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">好比周杰伦和周杰，其实并没有太大关系</span></font></div><div><br/></div><div><span style="font-size: 12pt;">   </span><img src="00-笔记_files/Image.jpg" type="image/jpeg" data-filename="Image.jpg" width="358"/>        <img src="00-笔记_files/Image [1].jpg" type="image/jpeg" data-filename="Image.jpg" style="font-size: 12pt;" width="354"/><span style="font-size: 12pt;">    </span></div><div><font style="font-size: 12pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt;"><br/></span></font></div><div><font style="font-size: 14pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 14pt; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">不过JS借鉴了很多Java的语法</span></span></font></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 14pt;"><br/></span></div><div><br/></div><div><span style="font-size: 16pt;">三足鼎立</span></div><div><br/></div><ul><li><div><span style="background-color: rgb(253, 252, 248);"><span style="background-color: rgb(253, 252, 248); font-size: 12pt;">Netscape Navigator 3.0 中的 JavaScript</span></span></div></li></ul><div><br/></div><ul><li><div><span style="background-color: rgb(253, 252, 248);"><span style="background-color: rgb(253, 252, 248); font-size: 12pt;">IE 中的 JScript </span></span></div></li></ul><div><br/></div><ul><li><div><span style="background-color: rgb(253, 252, 248);"><span style="background-color: rgb(253, 252, 248); font-size: 12pt;">CEnvi 中的 ScriptEase</span><span style="font-size: 12pt; background-color: rgb(253, 252, 248);"> （</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248); color: rgb(17, 17, 17); font-family: Verdana, Arial, Helvetica, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">一家称作 Nombas 的公司开发的可嵌入网页的脚本语言）</span></span></div></li></ul><div><br/></div><div><span style="background-color: rgb(253, 252, 248);"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; background-color: rgb(253, 252, 248);"><br/></span></span></div><div><span style="background-color: rgb(253, 252, 248);"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; background-color: rgb(253, 252, 248); color: rgb(17, 17, 17); font-family: Verdana, Arial, Helvetica, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">标准化</span></span></div><div><br/></div><div><span style="background-color: rgb(253, 252, 248);"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; background-color: rgb(253, 252, 248); color: rgb(17, 17, 17); font-family: Verdana, Arial, Helvetica, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="00-笔记_files/ISO.jpg" type="image/jpeg" data-filename="ISO.jpg" style="font-family: Verdana; font-size: 16pt; color: rgb(17, 17, 17);" width="172"/>   <img src="00-笔记_files/w3c.jpg" type="image/jpeg" data-filename="w3c.jpg" style="font-family: Verdana; font-size: 16pt; color: rgb(17, 17, 17);" width="254"/>    <img src="00-笔记_files/Image [2].png" type="image/png" data-filename="Image.png" style="font-family: Verdana; font-size: 16pt; color: rgb(17, 17, 17);" width="250"/></span></span></div><div><br/></div><div><br/></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(17, 17, 17); font-family: Verdana, Arial, Helvetica, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">ECMA</span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="color: rgb(51, 51, 51); font-family: arial; font-variant-caps: normal; font-variant-ligatures: normal; font-size: 12pt;">European Computer Manufacturers Association</span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="color: rgb(51, 51, 51); font-family: arial; font-variant-caps: normal; font-variant-ligatures: normal; font-size: 12pt;">欧洲计算机制造商协会</span></span></div><div><br/></div><div><img src="00-笔记_files/ecma.jpg" type="image/jpeg" data-filename="ecma.jpg" width="630"/></div><div><br/></div><div><br/></div><div><br/></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 12pt; color: rgb(17, 17, 17); font-variant-caps: normal; font-variant-ligatures: normal;">1997年，ECMA发布262号标准文件（ECMA-262）的第一版</span></span></div><div><br/></div><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(17, 17, 17); font-family: Verdana, Arial, Helvetica, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">1999年，ECMAScript 3.0发布</span></div><div><br/></div><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(17, 17, 17); font-family: Verdana, Arial, Helvetica, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">2015年6月，ECMAScript 6 <span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(17, 17, 17); font-family: Verdana, Arial, Helvetica, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">正式通过（ES6）</span></span></div><div><br/></div><div><br/></div><div><font style="font-size: 12pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(54, 101, 238); font-variant-caps: normal; font-variant-ligatures: normal;">ECMAScript 可以为不同种类的宿主环境提供核心的脚本编程能力，因此核心的脚本语言是与任何特定的宿主环境分开进行规定的... ...</span></font></div><div><br/></div><div><br/></div><div><font style="font-size: 18pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 18pt; font-variant-caps: normal; font-variant-ligatures: normal;">3.JS特点</span></font></div><div><div><br/></div><ul><li><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16px; color: rgb(119, 119, 119); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">解释性脚本语言</span></span></div></li></ul><div><br/></div><ul><li><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16px; color: rgb(119, 119, 119); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">运行在浏览器（浏览器内核带有js解释器，Chrome v8引擎）</span></span></div></li></ul><div><br/></div><ul><li><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16px; color: rgb(119, 119, 119); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">弱类型语言（松散型）</span></span></div></li></ul><div><br/></div><ul><li><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16px; color: rgb(119, 119, 119); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">事件驱动（动态）</span></span></div></li></ul><div><br/></div><ul><li><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16px; color: rgb(119, 119, 119); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">跨平台</span></span></div></li></ul><div><br/></div></div><div><br/></div><div><span style="font-size: 18pt;">4.JS用途</span></div><div><ul><li><div><font style="font-size: 12pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; color: rgb(121, 121, 121); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">嵌入动态文本</span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; color: rgb(121, 121, 121); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">于HTML页面</span></font></div></li><li><div><font style="font-size: 12pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; color: rgb(121, 121, 121); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">对浏览器事件做出响应</span></font></div></li><li><div><font style="font-size: 12pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; color: rgb(121, 121, 121); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">读写HTML元素</span></font></div></li><li><div><font style="font-size: 12pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; color: rgb(121, 121, 121); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">在数据被提交到服务器之前验证数据</span></font></div></li><li><div><font style="font-size: 12pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; color: rgb(121, 121, 121); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">检测访客的浏览器信息（可以使用js代码判断浏览器类型）</span></font></div></li><li><div><font style="font-size: 12pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; color: rgb(121, 121, 121); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">控制cookies</span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; color: rgb(121, 121, 121); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">，包括创建和修改等</span></font></div></li><li><div><font style="font-size: 12pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; color: rgb(121, 121, 121); font-family: &quot;Segoe UI Semibold&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">基于Node.js技术进行服务器端编程</span></font></div></li></ul></div><div style="margin: 0px; padding: 0px; list-style: none;"><div style="font-size: 14px; word-wrap: break-word; margin-bottom: 0px; text-indent: 0px; zoom: 1; margin-left: 25px;"><br/></div></div><div><span style="font-size: 14pt; color: rgb(255, 0, 0);">     视觉交互、</span><span style="white-space: pre-wrap; font-size: 14pt; color: rgb(255, 0, 0); font-family: &quot;Segoe UI Semibold&quot;;">数据交互、</span><span style="white-space: pre-wrap; font-size: 14pt; color: rgb(255, 0, 0); font-family: &quot;Segoe UI Semibold&quot;;">node.js（后台）</span></div><div><br/></div><div><span style="font-size: 18pt;">5.JS和H5的关系</span></div><div style="box-sizing: border-box; -webkit-margin-before: 1rem; -webkit-margin-after: 1rem; -webkit-margin-start: 0px; -webkit-margin-end: 0px; margin: 0.8em 0px; position: relative; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box;"><span style="box-sizing: border-box;"><span style="font-size: 14pt;"><span style="font-size: 14pt; color: rgb(51, 51, 51); font-family: 等线; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">页面三要素</span></span></span></div></div><ul style="box-sizing: border-box; margin: 0.8em 0px; padding-left: 30px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><li style="box-sizing: border-box; margin: 0px; position: relative;"><div style="box-sizing: border-box;"><span style="box-sizing: border-box;"><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">结构：HTML</span></span></div></li><li style="box-sizing: border-box; margin: 0px; position: relative;"><div style="box-sizing: border-box;"><span style="box-sizing: border-box;"><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">表现：CSS</span></span></div></li><li style="box-sizing: border-box; margin: 0px; position: relative;"><div style="box-sizing: border-box;"><span style="box-sizing: border-box;"><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">行为：JS</span></span></div></li></ul><div><span style="font-size: 12pt; font-family: &quot;Microsoft JhengHei&quot;;">   </span> <span style="font-size: 12pt;">H5是一种新的技术，就目前而言，我们所知的H5都是一些标签，但是<span style="font-size: 12pt; color: rgb(54, 101, 238);">有了JS之后，这些标签深层的扩展功能才得以实现。</span></span></div><div><span style="font-size: 12pt;">    比如video标签；我们对其理解为一个简单的标签；但是实际上，video标签还有更深层次的扩展功能；</span></div><div><br/></div><div><span style="font-size: 18pt;">6.JS书写位置</span></div><div><br/></div><div><ul><li><div><font style="font-size: 16pt;">内部js</font></div></li></ul><div><font style="font-size: 8pt;"><br/></font></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font face="等线" style="font-size: 14pt;">&lt;script&gt;  document.write('hello world')  &lt;/script&gt;</font></div></div><div><span style="font-size: 12pt;"><br/></span></div><ul><li><div><font style="font-size: 16pt;">外部js</font></div></li></ul><div><font style="font-size: 8pt;"><br/></font></div><div><font style="font-size: 12pt;">index.js文件</font></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font face="等线" style="font-size: 14pt;">console.log('hello world');</font></div></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt;">内部引入</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font face="等线" style="font-size: 14pt;">&lt;script src=&quot;path:to/index.js&quot;&gt;&lt;/script&gt;</font></div></div><div><span style="font-size: 12pt;"><br/></span></div><ul><li><div><span style="color: rgb(0, 0, 0); font-family: 微软雅黑; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">内联js</font></span></div></li></ul><div><font style="font-size: 8pt;"><br/></font></div></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-family: 等线; font-size: 14pt;">&lt;a href=&quot;alert('hello world')&quot;&gt;超链接&lt;/a&gt;</font></div><div><font face="等线" style="font-size: 14pt;">&lt;div onclick=&quot;alert('hello world')&quot;&gt;box&lt;/div&gt;</font></div></div><div><br/></div><div>        <span style="font-size: 12pt; color: rgb(255, 0, 0);">注意：</span></div><div><br/></div><div><span style="font-size: 12pt;">          1. script标签可以放在页面任何位置</span></div><div><br/></div><div><span style="font-size: 12pt;">          2.</span><span style="font-size: 12pt;">下面</span><span style="font-size: 12pt;">这样写是</span><span style="font-size: 12pt; color: rgb(227, 0, 0);">错误的！！！</span></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(227, 0, 0);">               </span> <span style="background-color: rgb(255, 250, 165);font-size: 12pt;-evernote-highlight:true;">&lt;script</span></span> <span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;"><span style="font-size: 16px;background-color: rgb(255, 250, 165);-evernote-highlight:true;">src=&quot;path:to/index.js&quot;</span><span style="font-size: 12pt;background-color: rgb(255, 250, 165);-evernote-highlight:true;">&gt;  </span></span></span></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt;">                <span style="font-size: 12pt;background-color: rgb(255, 250, 165);-evernote-highlight:true;">     </span><span style="font-size: 12pt;background-color: rgb(255, 250, 165);-evernote-highlight:true;">document.write</span><span style="font-size: 12pt;background-color: rgb(255, 250, 165);-evernote-highlight:true;">(&quot;hello world&quot;)  </span></span></span></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt;">                <span style="background-color: rgb(255, 250, 165);font-size: 12pt;-evernote-highlight:true;">&lt;/script&gt;</span></span></span></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(227, 0, 0);">       </span></span></div><div><br/></div><div><span style="font-size: 18pt;">7.向页面输出内容</span></div><div><br/></div><div><span style="font-size: 12pt;">    document.write(&quot;hello world&quot;);</span></div></div><div><br/></div><div><span style="font-size: 12pt;">    document.write(&quot;&lt;strong&gt;我很man&lt;/strong&gt;&quot;);</span></div><div><br/></div><div style="box-sizing: border-box; margin: 0px; padding: 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; font-size: 12pt; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;"><span style="font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal; font-family: &quot;Microsoft JhengHei&quot;;">    </span>转义字符:</span></div><div style="box-sizing: border-box; margin: 0px; padding: 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br style="box-sizing: border-box; font-size: 12pt;"/></div><div><span style="box-sizing: border-box; font-size: 12pt; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(0, 0, 0); font-family: &quot;Microsoft JhengHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">    &amp;lt; || &amp;gt;</span></div><div><br/></div><div><span style="font-size: 12pt;">    document.write(&quot;&amp;lt;strong&amp;gt;我很man&amp;lt;/strong&amp;gt;&quot;);</span></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt;"><br/></span></div><div><br/></div><div><span style="font-size: 18pt;">8.变量</span></div><div><span style="font-size: 12pt;">    </span></div><div><span style="font-size: 12pt;">    我需要500ml水，你怎么把水给我？</span></div><div><br/></div><div><span style="font-size: 12pt;">    需要一个杯子，来盛着500ml水</span></div><div><br/></div><div><span style="font-size: 12pt;">    <img src="00-笔记_files/杯子.png" type="image/png" data-filename="杯子.png" style="font-size: 12pt;" width="346"/></span></div><div><br/></div><div><span style="font-size: 12pt;">    当我需要的时候，你把这500ml水倒给我？</span></div><div><br/></div><div><span style="font-size: 12pt;">    还是直接把杯子给我？</span></div><div><br/></div><div><span style="font-size: 12pt;">    那你到底要给我哪个杯子？</span></div><div><br/></div><div><span style="font-size: 12pt;">    杯子有一些特性，蓝色的？高的？矮的？</span></div><div><br/></div><div><span style="font-size: 12pt;">    我们可以给杯子</span><span style="font-size: 12pt; color: rgb(54, 101, 238);">发个编号</span><span style="font-size: 12pt;">（起个名字）</span></div><div><br/></div><div><span style="font-size: 12pt;">    你把一号杯子给我，你把叫Lisa的那个杯子给我</span></div><div><br/></div><div><span style="font-size: 12pt;">   </span> <span style="font-size: 12pt; color: rgb(255, 0, 0);">其实，这样的思想就是变量</span></div><div><br/></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(255, 0, 0);"> </span><span style="font-size: 12pt;">   我们可以声明一个变量（拿出一个杯子），给变量起个变量名（给杯子编号），最后给变量赋值（在杯子里面改盛水）</span></span></div><div><br/></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt;">    当我们需要这一数据的时候（需要水的时候），只需拿到变量名（杯子编号）即可</span></span></div><div><br/></div><div><br/></div><div><span style="font-size: 12pt;">   </span><font style="font-size: 14pt;"><span style="font-size: 14pt; font-family: 等线; font-weight: bold;"> </span><span style="font-size: 14pt; font-family: 等线; font-weight: bold;">变量声明：</span></font></div><div><br/></div><div><span style="font-size: 14pt;">       </span> <span style="font-size: 12pt;">var a = &quot;hello world&quot;；</span></div><div><div><br/></div><table style="border-collapse: collapse; min-width: 100%;"><colgroup><col style="width: 239px;"></col><col style="width: 203px;"></col></colgroup><tbody><tr><td style="border: 1px solid rgb(204, 204, 204); width: 239px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">var </span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 203px; padding: 8px;"><div><span style="font-size: 12pt;">声明变量的关键字</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 239px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">a   </span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 203px; padding: 8px;"><div><span style="font-size: 12pt;">变量名</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 239px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">    =       </span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 203px; padding: 8px;"><div><span style="font-size: 12pt;">赋值  </span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 239px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">&quot;hello world&quot;</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 203px; padding: 8px;"><div><span style="font-size: 12pt;">变量的值</span></div></td></tr></tbody></table><div><br/></div></div><div><span style="font-size: 12pt;">      声明变量的时候计算机到底干了什么事呢？</span></div><div><br/></div><div><span style="font-size: 12pt; font-family: &quot;Microsoft JhengHei&quot;;">       </span><span style="font-size: 12pt;">我们所写的程序运行在内存中，当我们使用关键字var 声明一个变量的时候，计算机会从内存中留出一定储存空    间，为我们存放</span><span style="font-size: 12pt; color: rgb(255, 122, 116);">不同类型</span><span style="font-size: 12pt;">的内容。</span></div><div><br/></div><div><span style="font-size: 12pt; color: rgb(255, 0, 0);">地址指的是内存的编号</span></div><div><span style="font-size: 12pt; color: rgb(255, 0, 0);">指针就是指向某个地址的工具，去取到这个地址对应的内存里面的值</span></div><div><br style="font-size: 12pt;"/></div><div><span style="font-size: 12pt;">      分清左右两侧的意义：</span></div><div><br style="font-size: 12pt;"/></div><div><span style="font-size: 12pt;">       JavaScript中的 ‘’=‘’ 和我们数学中的 ‘’ = ‘’不一样，在JavaScript中‘’=‘’的作用是赋值（取别称）。 </span></div><div><span style="font-size: 12pt;">       </span></div><div><span style="font-size: 12pt;">       <span style="font-size: 12pt;">var a = &quot;hello world&quot;</span></span><span style="font-size: 12pt;">;  这句话分成两个部分。</span></div><div><span style="font-size: 12pt;">    </span></div><div><span style="font-size: 12pt;">     </span> <span style="font-size: 12pt; color: rgb(129, 182, 255);">左值：在等号左侧，是声明一个变量并且起名</span></div><div><span style="font-size: 12pt;">     </span></div><div><span style="font-size: 12pt;">    </span>  <span style="font-size: 12pt; color: rgb(229, 0, 255);">右值 ：在等号右侧，是存放进变量中的东西（给变量赋值）</span></div><div><br style="font-size: 12pt;"/></div><div><span style="font-size: 12pt;">     </span> <span style="font-size: 16pt;">变量的类型</span></div><div><br/></div><div><span style="font-size: 12pt;">     （因为存放进变量中的数据是放在内存中的，计算机只识别0，1，所以需要对不同类型的数据进行编码，编码的结果会导致所需空间不同，所以JavaScript中分成很多种数据类型，以便计算机储存时使用）</span></div><div><br style="font-size: 12pt;"/></div><ul><li><div><span style="font-size: 12pt;">     数字类型(number)：1234567890   int（</span><span style="font-size: 12pt;">integer</span><span style="font-size: 12pt;">）：整型        float：浮点型（小数）</span></div></li></ul><div><br style="font-size: 12pt;"/></div><ul><li><div><span style="font-size: 12pt;">     字符类型(string)：'123456',&quot;字符串类型&quot;,.....（有单引号或者双引号）</span></div></li></ul><div><br style="font-size: 12pt;"/></div><ul><li><div><span style="font-size: 12pt;">     未定义类型(undefined)：这是一种特殊类型，当变量被声明但是没有被赋值的时候，那么该变量的类型为undefined；</span></div></li></ul><div><br style="font-size: 12pt;"/></div><ul><li><div><span style="font-size: 12pt;">   </span> <span style="font-size: 12pt; color: rgb(121, 121, 121);"> </span><span style="font-size: 12pt;">布尔值类型（</span><span style="font-size: 12pt;">boolean</span><span style="font-size: 12pt;">）：true，false；</span></div></li></ul><div><br style="font-size: 12pt;"/></div><ul><li><div><span style="font-size: 12pt; color: rgb(121, 121, 121);">     对象类型：object；</span></div></li></ul><div><span style="font-size: 12pt;"><br/></span></div><ul><li><div><span style="font-size: 12pt; color: rgb(121, 121, 121);">     数组类型（array）；</span></div></li></ul><div><span style="font-size: 12pt; color: rgb(121, 121, 121);">    </span></div><ul><li><div><span style="font-size: 12pt; color: rgb(121, 121, 121);">     函数类型：Function；</span></div></li></ul><div><br/></div><ul><li><div><span style="font-size: 12pt; color: rgb(121, 121, 121);">    symbol --- ES6新增</span></div></li></ul><div><br/></div><div><br style="font-size: 12pt;"/></div><div><span style="font-size: 12pt;">     怎样直观地区分不同的数据类型那？</span></div><div><br style="font-size: 12pt;"/></div><div><span style="font-size: 12pt;">     一个关键字 </span><span style="font-size: 12pt; color: rgb(255, 122, 116);">typeof</span></div><div><span style="font-size: 12pt;">     </span></div><div><span style="font-size: 12pt;">   <span style="font-size: 12pt; color: rgb(255, 0, 0);"> </span><span style="font-size: 12pt; color: rgb(255, 0, 0);">    typeof返回有六种值： number、string、boolean、undefined、object</span><span style="font-size: 12pt; color: rgb(255, 0, 0);">、function</span></span></div><div>            </div><div><br/></div><div>          <span style="font-size: 12pt; color: rgb(227, 0, 0);">js有五（六）种基本数据类型：</span><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(255, 0, 0);">number、string、boolean、</span><span style="font-size: 12pt; color: rgb(255, 0, 0);">undefined</span><span style="font-size: 12pt; color: rgb(255, 0, 0);">、null、</span><span style="font-size: 12pt; color: rgb(45, 79, 201);">（</span><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(45, 79, 201);">symbol）</span></span></span></div><div><font style="font-size: 12pt;"><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(255, 0, 0);">        两种引用类型：object、function</span></span></font></div><div><span style="font-size: 12pt;">         </span></div><div><span style="font-size: 12pt;">        </span></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(255, 0, 0);">        从另外一个角度来说：JS有两种特殊数据类型： null、undefined</span></span></div><div><br/></div><div><br/></div><div><span style="font-size: 12pt;">变量使用小技巧: 声明一串变量:var a=1,b=2,c=3;</span></div><div><span style="font-size: 14pt;">       </span></div><div><span style="font-size: 14pt;">    js语言里面的分号可以省略</span></div><div><span style="font-size: 12pt;">    </span></div><div><span style="font-size: 12pt;">   </span> <span style="font-size: 18pt; color: rgb(54, 101, 238);">变</span><span style="font-size: 12pt;">量：可变的量</span></div><div><br/></div><div><span style="font-size: 12pt;">     var a = &quot;hello world&quot;;</span></div><div><br/></div><div><span style="font-size: 12pt;">     a = &quot;</span><span style="font-size: 12pt;">&lt;strong&gt;我很man&lt;/strong&gt;</span><span style="font-size: 12pt;">&quot;;</span></div><div><br/></div><div><span style="font-size: 12pt;">   </span> <span style="font-size: 12pt; color: rgb(227, 0, 0);">注意：</span><span style="font-size: 12pt; color: rgb(227, 0, 0);"> </span> <span style="font-size: 12pt; color: rgb(227, 0, 0);">再次修改变量的值的不是不需要再写 var</span><span style="background-color: rgb(255, 250, 165);font-size: 12pt;-evernote-highlight:true;">（相当于你往杯子里重新倒水不需要拿一个新的杯子）</span></div><div><span style="font-size: 12pt;">    </span></div><div><br/></div><div><span style="font-size: 12pt;">   </span> <span style="font-size: 18pt; color: rgb(54, 101, 238);">弱</span><span style="font-size: 12pt;">类型 </span></div><div><br/></div><div><span style="font-size: 12pt;">          声明变量的时候无需声明类型</span></div><div><span style="font-size: 12pt;">         </span></div><div><span style="font-size: 12pt;">          同一个变量可以修改存储不同类型的数据，例如：</span></div><div><br/></div><div><span style="font-size: 12pt;">            <span style="font-size: 12pt;">var a = &quot;hello world&quot;;</span></span></div><div><span style="font-size: 12pt;">            a = 123</span><span style="font-size: 12pt;">;</span></div><div><br/></div><div><span style="font-size: 12pt;">           <span style="font-size: 12pt; color: rgb(121, 121, 121);">类比强类型语言，如：Java</span></span></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(121, 121, 121);">             String a = &quot;Hello world&quot;;</span></span></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(121, 121, 121);">             a = 123;</span> <span style="font-size: 12pt; color: rgb(121, 121, 121);">// 报错！！！</span></span></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 12pt; font-family: &quot;Microsoft JhengHei&quot;;">    </span><font style="font-size: 14pt;"><span style="font-size: 14pt; font-family: 等线; font-weight: bold;">变量命名规范：（匈牙利命名法：驼峰命名法）</span></font></div><div><br style="font-size: 12pt;"/></div><div><span style="font-size: 12pt; font-family: &quot;Microsoft JhengHei&quot;;">   </span> <span style="font-size: 12pt;"> 为什么要存在命名规范那？</span></div><div><br style="font-size: 12pt;"/></div><div><span style="font-size: 12pt;">     你的代码并不是只有你一个人看，变量既然是别称，那么别称就要有特殊的含义：</span></div><div><br style="font-size: 12pt;"/></div><div><span style="font-size: 12pt;">     </span><span style="font-size: 12pt; color: rgb(167, 69, 0);">举个栗子</span><span style="font-size: 12pt;">：翠花，我们能从这个名字中得到什么信息呢？（这个名字的主人性别应该是女的，家中父母的一个美好愿景）；</span></div><div><span style="font-size: 12pt;">     </span></div><div><span style="font-size: 12pt;">     那么二蛋呢？</span></div><div><br/></div><div>       <img src="00-笔记_files/二蛋.png" type="image/png" data-filename="二蛋.png" style="font-size: 12pt;" width="268"/></div><div><span style="font-size: 12pt;"> </span></div><div><span style="font-size: 12pt;">     我们从这些名字中能够读出很多的含义，是因为我们的语言常识，同样，变量也有一套类似的标准，代表了各种各样的含义，这些含义如下：</span></div><div><span style="font-size: 12pt; font-family: &quot;Microsoft JhengHei&quot;;">     </span></div><div><br style="font-size: 12pt;"/></div><div style="text-align: center;"><div style="font-size: 12pt;"><span style="font-size: 12pt; font-family: &quot;Microsoft JhengHei&quot;;"> </span><span style="font-size: 12pt;"><img src="00-笔记_files/Image [3].png" type="image/png" data-filename="Image.png" style="height: auto; font-size: 12pt;"/></span></div></div><div><span style="font-size: 12pt; font-family: &quot;Microsoft JhengHei&quot;;">     </span></div><div><span style="font-size: 12pt; font-family: &quot;Microsoft JhengHei&quot;;">     </span><span style="font-size: 12pt;">第二个规则：</span></div><div><br style="font-size: 12pt;"/></div><div><span style="font-size: 12pt;">     </span><span style="letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(51, 51, 51); font-variant-caps: normal; font-variant-ligatures: normal;">变量名首字符必须为字母(</span><span style="font-size: 12pt; color: rgb(250, 122, 0); font-variant-caps: normal; font-variant-ligatures: normal;">a-z A-Z</span><span style="font-size: 12pt; color: rgb(51, 51, 51); font-variant-caps: normal; font-variant-ligatures: normal;">)，下划线( </span><span style="font-size: 12pt; color: rgb(250, 122, 0); font-variant-caps: normal; font-variant-ligatures: normal;">_ </span><span style="font-size: 12pt; color: rgb(51, 51, 51); font-variant-caps: normal; font-variant-ligatures: normal;">)，或者美元符号( </span><span style="font-size: 12pt; color: rgb(250, 122, 0); font-variant-caps: normal; font-variant-ligatures: normal;">$ </span><span style="font-size: 12pt; color: rgb(51, 51, 51); font-variant-caps: normal; font-variant-ligatures: normal;">)开始  </span></font></span></div><div>     </div><div><span style="font-size: 12pt; color: rgb(70, 70, 70);">     余下的字符可以是下划线、美元符号或任何字母或数字字符</span></div><div><br/></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(45, 79, 201);">    </span><span style="font-size: 12pt; color: rgb(45, 79, 201);"> </span><span style="font-size: 12pt; color: rgb(70, 70, 70);">变量名大小写敏感（var a 和  var A 是不一样的两个变量）</span></span></div><div><br style="font-size: 12pt;"/></div><div style="text-align: left;"><span style="font-size: 12pt;">     想要用 function作为变量可不可以呢？  </span></div><div style="text-align: left;"><span style="font-size: 12pt;">    </span></div><div style="text-align: left;"><div style="font-size: 12pt;"><br style="font-size: 12pt;"/></div></div><div style="text-align: left;"><font style="font-size: 14pt;"><span style="font-size: 14pt; font-family: 等线; font-weight: bold;">关键字：</span></font></div><div style="text-align: left;"><div style="font-size: 12pt;"><br style="font-size: 12pt;"/></div></div><div style="text-align: left;"><span style="font-size: 12pt; background-color: rgb(252, 252, 252); color: rgb(51, 51, 51);">这些关键字用于执行特定操作等。</span><span style="font-size: 12pt; background-color: rgb(252, 252, 252); color: rgb(255, 122, 116);">按照规则，关键字也是语言保留的，不能用作标识符。</span></div><table style="text-align: left; background-color: rgb(255, 255, 255); table-layout: fixed; border-collapse: collapse; min-width: 100%;"><colgroup><col style="width: 214px;"></col><col style="width: 183px;"></col><col style="width: 214px;"></col><col style="width: 138px;"></col></colgroup><tbody><tr><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">break</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 183px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">do</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">instanceof</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 138px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">typeof</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">case</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 183px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">else</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">new</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 138px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">var</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">catch</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 183px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">finally</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">return</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 138px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">void</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">continue</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 183px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">for</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">switch</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 138px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">while</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">debugger*</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 183px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">function</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">this</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 138px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">with</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">default</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 183px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">if</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">throw</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 138px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">delete</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">in</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 183px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">try</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 214px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;"> </span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 138px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;"> </span></div></td></tr></tbody></table><div style="text-align: center;"><div style="font-size: 12pt;"><br style="font-size: 12pt;"/></div></div><div style="text-align: left;"><span style="font-size: 14pt; font-family: 等线; font-weight: bold;">保留字：未来可能作为，标识符存在</span></div><table style="text-align: left; background-color: rgb(255, 255, 255); table-layout: fixed; border-collapse: collapse; min-width: 100%;"><colgroup><col style="width: 168px;"></col><col style="width: 222px;"></col><col style="width: 176px;"></col><col style="width: 184px;"></col></colgroup><tbody><tr><td style="border: 1px solid rgb(204, 204, 204); width: 168px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">abstract</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 222px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">enum</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 176px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">int</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 184px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">short</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 168px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">boolean</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 222px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">export</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 176px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">interface</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 184px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">static</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 168px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">byte</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 222px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">extends</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 176px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">long</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 184px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">super</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 168px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">char</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 222px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">final</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 176px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">native</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 184px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">synchronized</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 168px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">class</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 222px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">float</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 176px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">package</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 184px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">throws</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 168px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">const</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 222px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">goto</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 176px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">private</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 184px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">transient</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 168px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">debugger</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 222px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">implements</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 176px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">protected</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 184px; padding: 8px;"><div style="text-align: center;"><span style="background-color: rgb(255, 255, 255); font-size: 12pt;">volatile</span></div></td></tr><tr><td style="border: 1px solid rgb(204, 204, 204); width: 168px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">double</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 222px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">import</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 176px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">public</span></div></td><td style="border: 1px solid rgb(204, 204, 204); width: 184px; padding: 8px;"><div style="text-align: center;"><span style="font-size: 12pt;">name </span></div></td></tr></tbody></table><div><br/></div><div><span style="font-size: 12pt; color: rgb(54, 101, 238);">     </span> <span style="font-size: 12pt;">   </span></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 18pt;">9.运算符</span></div><div><br/></div><div><span style="font-size: 14pt;">程序：数据结构 + 算法</span></div><div><span style="font-size: 14pt;">做饭：材料+做法</span></div><div><br/></div><div><span style="font-size: 14pt;"><img src="00-笔记_files/做饭.png" type="image/png" data-filename="做饭.png" style="font-size: 14pt;" width="445"/></span></div><div><br/></div><div><span style="font-size: 14pt;">算数运算符</span></div><div><span style="font-size: 18.6667px;">  </span> <span style="font-size: 12pt;">加、减、乘、除、求余/取模（+ 、- 、* 、/ 、%）</span></div><div><br/></div><div><span style="font-size: 12pt;">余数： a/b整除之外的剩余的数字</span></div><div><span style="font-size: 12pt;">10 / 3 = 3 ...</span> <span style="font-size: 12pt; color: rgb(227, 0, 0);">1</span></div><div><span style="font-size: 12pt;">10 % 3 = 1</span></div><div><br/></div><div><span style="font-size: 12pt;">3 % 10 = 3</span></div><div><br/></div><div><span style="font-size: 12pt;">取余：大数对小的那个数取余结果为整除之后的余数</span></div><div><span style="font-size: 12pt;">          小的那个数对大数求余的结果就是小的那个数本身</span></div><div><br/></div><div><span style="font-size: 12pt;">            </span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 12pt; font-family: 等线;">var a = 1, b = 2;</font></div><div><font face="等线" style="font-size: 12pt;">a + b == 3</font></div><div><font face="等线" style="font-size: 12pt;">a - b == -1</font></div><div><font face="等线" style="font-size: 12pt;">a * b == 2</font></div><div><font face="等线" style="font-size: 12pt;"><span style="color: rgb(51, 51, 51);">a / b == 0.5</span></font></div><div><br/></div></div><div><br/></div><div><br/></div><div><span style="font-size: 14pt;">关系运算符</span></div><div><br/></div><div><span style="font-size: 14pt;"> </span> <span style="font-size: 12pt;">==（相等） 、!=（不等于）、&lt;（小于） 、&gt;（大于） 、&lt;=（小于或者等于） 、&gt;=（大于或者等于）</span></div><div><br/></div><div><span style="font-size: 14pt;">   </span> <span style="font-size: 12pt; color: rgb(54, 101, 238);">判断运算符两侧的结果是否满足规则，满足结果即为true，否则false</span></div><div><br/></div><div>             <span style="font-size: 12pt;">5 != 3     true</span></div><div>  <span style="font-size: 12pt;">         5 &lt; 3      false</span></div><div><span style="font-size: 12pt;">           </span><span style="font-size: 12pt;">5 &lt;= 5   true</span></div><div><br/></div><div><br/></div><div><span style="font-size: 12pt;">= 和 == 以及 === 的区别</span></div><div><span style="font-size: 12pt;"><br/></span></div><ul><li><div><span style="font-size: 12pt;">一个等号是赋值，将等号右边的值赋给左边</span></div></li></ul><div><span style="font-size: 12pt;"><br/></span></div><ul><li><div><span style="font-size: 12pt;">两个等号是判断相等，相等结果为true，不等为false，不考虑数据类型，只判断值</span></div></li></ul><div><span style="font-size: 12pt;"><br/></span></div><ul><li><div><span style="font-size: 12pt;">三个等号要求全等，不仅值要相等，类型也必须相等</span></div></li></ul><div><span style="font-size: 12pt;">   </span></div><div><span style="font-size: 12pt;"><br/></span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><span style="font-family: 等线; font-size: 12pt; color: rgb(51, 51, 51);">var a = 2, b = “2”;</span></div><div><br/></div><div><span style="font-family: 等线; font-size: 12pt; color: rgb(51, 51, 51);">a == b  // true</span></div><div><span style="font-family: 等线; font-size: 12pt; color: rgb(51, 51, 51);">             </span></div><div><span style="font-family: 等线; font-size: 12pt; color: rgb(51, 51, 51);">a === b // false</span></div><div><br/></div><div><span style="font-family: 等线; font-size: 12pt;"><font color="#E30000">a + b  == ？？？</font></span></div><div><span style="font-family: 等线; font-size: 12pt; color: rgb(51, 51, 51);">               </span></div></div><div><br/></div><div><br/></div><div><span style="font-size: 14pt;">逻辑运算符</span></div><div><br/></div><ul style="box-sizing: border-box; margin: 0px; padding-left: 30px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><li style="box-sizing: border-box; margin: 0px; position: relative;"><div style="box-sizing: border-box;"><span style="box-sizing: border-box;"><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">逻辑与：&amp;&amp;</span></span></div></li></ul><div><br/></div><div><span style="box-sizing: border-box; font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;">        “和”的意思</span></div><div><span style="box-sizing: border-box; font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;">        我和彭于晏都是帅哥</span></div><div><br/></div><div><span style="box-sizing: border-box; font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;">           <span style="background-color: rgb(255, 250, 165); font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;-evernote-highlight:true;">必须两个条件均为true结果才为true</span></span></div><div><br/></div><ul style="box-sizing: border-box; margin: 0px; padding-left: 30px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><li style="box-sizing: border-box; margin: 0px; position: relative;"><div style="box-sizing: border-box;"><span style="box-sizing: border-box;"><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">逻辑或：||</span></span></div></li></ul><div><br/></div><div><span style="box-sizing: border-box; font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;">        “</span><span style="font-size: 16px; white-space: pre-wrap; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;">或</span><span style="box-sizing: border-box; font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;">”</span><span style="font-size: 16px; white-space: pre-wrap; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;">的意思</span></div><div><span style="box-sizing: border-box; font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;">        我或彭于晏是帅哥  </span></div><div><br style="font-family: Open Sans; font-size: 12pt; color: rgb(51, 51, 51);"/></div><div><span style="box-sizing: border-box; font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;">         </span> <span style="box-sizing: border-box; font-size: 12pt; background-color: rgb(255, 250, 165); color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;-evernote-highlight:true;">只要有一个条件为true结果就为true</span></div><div><span style="box-sizing: border-box; font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;">         </span> <span style="box-sizing: border-box; font-size: 12pt; background-color: rgb(255, 250, 165); color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;-evernote-highlight:true;">必须两个条件均为false结果才为false</span></div><div><br/></div><ul style="box-sizing: border-box; margin: 0px; padding-left: 30px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><li style="box-sizing: border-box; margin: 0px; position: relative;"><div style="box-sizing: border-box;"><span style="font-size: 12pt;">逻辑非：!</span></div></li></ul><div><br/></div><div><span style="font-size: 16px; white-space: pre-wrap;">        “不”的意思</span></div><div><span style="font-size: 16px; white-space: pre-wrap; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;">            我不是帅哥</span></div><div><br/></div><div><span style="font-size: 16px; white-space: pre-wrap;"><span style="background-color: rgb(255, 250, 165); font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Clear Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;-evernote-highlight:true;">            对本身的结果取反</span></span></div><div><br/></div><div><br/></div><div><span style="background-color: rgb(255, 250, 165); font-family: &quot;Open Sans&quot;;-evernote-highlight:true;"><img src="00-笔记_files/Image [4].png" type="image/png" data-filename="Image.png" width="661"/></span></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 12pt; color: rgb(255, 0, 0);">与逻辑在两个条件均为true时结果才为true，其余情况均为false</span></div><div><span style="font-size: 12pt; color: rgb(255, 0, 0);">或逻辑在两个条件均为false时结果才为false，其余情况均为true</span></div><div><br/></div><div><br/></div><div><span style="font-size: 18pt;">练习</span></div><div><br/></div><div><span style="font-size: 12pt;">1．为抵抗洪水，战士连续作战89小时，编程计算共多少天零多少小时？</span></div><div><br/></div><div><span style="font-size: 12pt;">2．小明要到美国旅游，可是那里的温度是以华氏度为单位记录的。</span></div><div><span style="font-size: 12pt;">     它需要一个程序将华氏温度（80度）转换为摄氏度，并以华氏度和摄氏度为单位分别显示该温度。</span></div><div><span style="font-size: 12pt;">   </span></div><div><span style="font-size: 12pt;">  提示：摄氏度与</span><span style="font-size: 12pt;">华</span><span style="font-size: 12pt;">氏度的转换公式为：摄氏度 = 5/9.0*(华氏度-32)保留3位小数</span></div><div><br/></div><div><br/></div><div><br/></div><div><font style="font-size: 18pt;"><span style="white-space: pre-wrap; font-size: 18pt; color: rgb(51, 51, 51);">10.变量类型转换</span></font></div><div><br/></div><div><br/></div><div><span style="font-size: 14pt;">隐式转换</span><span style="font-size: 14pt;"> </span></div><div><br/></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font face="等线" style="font-size: 14pt;"><span style="color: rgb(51, 51, 51);">var a = &quot;2&quot;, b = 2;</span></font></div><div><font face="等线" style="font-size: 14pt;">console.log(a + b  )        // 22</font></div><div><font face="等线" style="font-size: 14pt;">console.log(<font><font color="#000000">a == b)       //  true</font></font></font></div><div><font><font style="font-size: 14pt; font-family: 等线; color: rgb(0, 0, 0);">console.log(a * b)          // 4</font></font></div><div><font><font color="#000000" face="等线" style="font-size: 14pt;">console.log(a - 0 + b)   // 4</font></font></div><div><font style="font-size: 14pt; font-family: 等线;">console.log(a / b)          // 1</font></div><div><font face="等线" style="font-size: 14pt;">console.log(a % b)          // 0</font></div></div><div><span style="font-size: 14pt;">    </span></div><div><span style="font-size: 14pt;">显式转换</span></div><div><br/></div><div><span style="font-size: 14pt;">    parseInt()、parseFloat()、Number()、toString()、String()</span></div><div><span style="font-size: 14pt;">   <span style="font-size: 14pt; color: rgb(255, 0, 0);"> </span><span style="font-size: 14pt; color: rgb(255, 0, 0);">toFixed()可以用来将数字保留几位小数，并且数据类型变为字符串</span></span></div><div><br/></div><div><br/></div><div><br/></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><span style="font-family: 等线; color: rgb(51, 51, 51);"><font style="font-size: 14pt;">var a = 2, b = “2”;</font></span></div><div><span style="font-family: 等线;"><font color="#000000" style="font-size: 14pt;">a + parseInt(b)  === 4   // true</font></span></div><div><span style="font-family: 等线;"><font color="#000000" style="font-size: 14pt;"><br/></font></span></div></div><div><br/></div><div><br/></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><span style="background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;">    parseInt() 方法首先查看位置 0 处的字符，判断它是否是个有效数字；如果不是，该方法将返回 NaN，不再继续执行其他操作。</span> <span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;">但如果该字符是有效数字，该方法将查看位置 1 处的字符，进行同样的测试。这一过程将持续到发现非有效数字的字符为止，此时 parseInt() 将把该字符之前的字符串转换成数字。</span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248); color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 14pt;"><br/></font></span></span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><font style="font-size: 14pt; font-family: 等线;">parseInt(&quot;20b3&quot;)       // 20</font></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><font style="font-size: 14pt; font-family: 等线;">parseInt(&quot;b20&quot;)       //  NaN</font></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><font style="font-size: 14pt; font-family: 等线;">parseInt(&quot;20.99&quot;)    // 20</font></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><font style="font-size: 14pt; font-family: 等线;"><br/></font></span></div></div><div><br/></div><div><br/></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><span style="background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;">    parseFloat()跟parseInt()极其相似，不过第一个出现的小数点是有效字符。如果有两个小数点，第二个小数点将被看作无效的。parseFloat() 会把这个小数点之前的字符转换成数字。</span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><span style="background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;"><br/></span></span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><font face="等线" style="font-size: 14pt;">parseFloat(&quot;11.22.33&quot;)   // 11.22</font></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><font face="等线" style="font-size: 14pt;">parseFloat(&quot;11.212be&quot;)  // 11.212</font></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><font face="等线" style="font-size: 14pt;"><br/></font></span></div></div><div><br/></div><div><span style="font-size: 12pt;"><br/></span></div><div><br/></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><span style="background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;">    Number() 是一个非常严格的转换，只要不满足数字，都会直接转换为NaN</span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><span style="background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;"><br/></span></span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><font face="等线"><font style="font-size: 14pt;">Number(&quot;20b3&quot;)       // NaN</font></font></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><font face="等线"><font style="font-size: 14pt;">Number(&quot;b20&quot;)       //  NaN</font></font></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><font face="等线"><font style="font-size: 14pt;">Number(&quot;20.99&quot;)    // 20.99</font></font></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><font face="等线"><font style="font-size: 14pt;">Number(&quot;20&quot;)        // 20</font></font></span></div></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 16pt;">NaN：Not a Number</span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><span style="background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(0, 0, 0); font-family: PingFangSC-Regular, Verdana, Arial, 微软雅黑, 宋体; font-variant-caps: normal; font-variant-ligatures: normal;">     </span><span style="background-color: rgb(253, 252, 248); font-size: 12pt; color: rgb(0, 0, 0); font-variant-caps: normal; font-variant-ligatures: normal;">是一个特殊值，说明某些算术运算（如求负数的平方根）的结果不是数字（本来期望得到一个数字，但是结果没有计算成功）。方法 parseInt() 和 parseFloat() 在不能解析指定的字符串时就返回这个值</span></span></div><div><br/></div><div><font style="font-size: 14pt;"><span style="font-family: &quot;Microsoft JhengHei&quot;; font-size: 14pt; font-weight: bold;">isNaN(num)函数，该函数判断num变量的值是否是NaN，是NaN返回true，数字返回false</span></font></div><div><br/></div><div><br/></div><div style="margin: 12px 0px 0px; padding: 0px; border: 0px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><span style="border: 0px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><span style="background-color: rgb(253, 252, 248); font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 21px;">ECMAScript 中可用的 3 种强制类型转换如下：</span></span></div><ul style="margin: 10px 0px 0px 35px; padding: 0px; border: 0px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(253, 252, 248);"><li style="margin: 3px 0px 0px; padding: 0px; border: 0px;"><div><span style="font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">Boolean(value) - 把给定的值转换成 Boolean 型；</span></div></li><li style="margin: 3px 0px 0px; padding: 0px; border: 0px;"><div><span style="font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">Number(value) - 把给定的值转换成数字（可以是整数或浮点数）；</span></div></li><li style="margin: 3px 0px 0px; padding: 0px; border: 0px;"><div><span style="font-size: 12pt; font-variant-caps: normal; font-variant-ligatures: normal;">String(value) - 把给定的值转换成字符串；</span></div></li></ul><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 16pt;">运算符的简写</span></div><div><br/></div><div><span style="font-size: 14pt;">  赋值运算简写</span></div><div><br/></div><div><span style="font-size: 14pt;">   +=、-=、*=、/=</span></div><div><br/></div><div><span style="font-size: 14pt;">   a = a + 1      a += 1</span></div><div><span style="font-size: 14pt;">   a = a  - 1      a  -= 1</span></div><div><span style="font-size: 14pt;">   a = a  * 1      a  *= 1</span></div><div><span style="font-size: 14pt;">   a = a  / 1      a  /= 1</span></div><div><span style="font-size: 14pt;">  </span></div><div>    <font style="font-size: 14pt;"><span style="font-size: 14pt;">a++    <span style="font-size: 14pt;">a += 1     a = a + 1</span></span></font></div><div><span style="font-size: 14pt;">   a--      </span><span style="font-size: 14pt;">a  -= 1     a = a -  1</span></div><div><br/></div><div><br/></div><div><span style="font-size: 18pt;"> </span> <span style="font-size: 18pt; color: rgb(54, 101, 238);">++a    --a</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font><font face="微软雅黑" style="font-size: 14pt;">var a = 10;</font></font></div><div style="font-size: 14pt;"><font><font style="font-family: 微软雅黑; color: rgb(0, 0, 0);">console.log(a++);     10</font></font></div><div style="font-size: 14pt;"><div><font><font style="font-family: 微软雅黑; color: rgb(0, 0, 0);"><span style="font-family: 微软雅黑; color: rgb(0, 0, 0); font-size: 14pt;">console.log(a);          11 </span></font></font></div></div><div style="font-size: 14pt;"><div><font><font color="#000000" face="微软雅黑"><span style="color: rgb(0, 0, 0); font-size: 14pt;">console.log(++a);     12</span></font></font></div></div></div><div><font style="font-size: 14pt;"><span style="font-size: 14pt; color: rgb(54, 101, 238);">    </span></font></div><div><span style="font-size: 12pt; color: rgb(227, 0, 0);">    自增自减前置后置是不一样的，前置是先加后用，后置的先用后加。</span></div><div><br/></div><div><span style="font-size: 12pt; color: rgb(227, 0, 0); font-family: &quot;Microsoft JhengHei&quot;;"> </span> <span style="font-size: 12pt; font-family: &quot;Microsoft JhengHei&quot;;">--- </span><span style="font-size: 16pt; font-family: &quot;Microsoft JhengHei&quot;;">var k=0;  console.log(k++ + ++k +k +k++);  console.log(k);</span></div><div><span style="font-size: 12pt;"> </span></div><div><br/></div><div><span style="font-size: 18pt;">进制</span></div><div><br/></div><div><span style="font-size: 14pt;">什么是进制？  </span></div><div><br/></div><div><span style="font-size: 18.6667px;">    我们接触的数字一般都是十进制，比如 iPhoneX价格8868，默认就是10进制，因为我们习惯了他的贵。</span></div><div><span style="font-size: 18.6667px;">    再比如：1小时等于60分钟，那这就是60进制，逢60进一</span></div><div><span style="font-size: 18.6667px;">    一天等于24小时，24进制，每24小时就是一天，小时数清零</span></div><div><br/></div><div><br/></div><div><span style="font-size: 12pt;">十进制： 0123456789                  1</span><span style="font-size: 12pt;">2</span><span style="font-size: 12pt;">3    ---&gt;    3 * 10^0 + 2 * 10^1 + 1 * 10^2 </span></div><div><font style="font-size: 18pt;"><span style="font-size: 12pt;">二进制： 01                                  101    ---&gt;    1 * 2^0 + 0 * 2^1 + 1 * 2^2</span></font></div><div><font style="font-size: 18pt;"><span style="font-size: 12pt;">八进制<span style="font-size: 12pt;">： 01234567                      <span style="font-size: 12pt;">147    ---&gt;    7 * 8^0 + 4 * 8^1 + 1 * 8^2</span></span></span></font></div><div><font style="font-size: 18pt;"><span style="font-size: 12pt;"><span style="font-size: 12pt;"><span style="font-size: 12pt;">十六<span style="font-size: 12pt;">进制：</span><span style="font-size: 12pt;">0123456789abcdef</span><span style="font-size: 12pt;">     1fa    ---&gt;    10 * 16^0 + 15 * 16^1 + 1 * 16^2</span></span></span></span></font></div><div><br/></div><div><span style="font-size: 14pt;">进制转换----&gt; toString(进制数)</span></div><div><br/></div></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><span style="background-color: rgb(251, 250, 248); color: rgb(51, 51, 51);"><font face="微软雅黑" style="font-size: 12pt;">var a = 072;  //八进制      58</font></span></div><div><span style="background-color: rgb(251, 250, 248); color: rgb(51, 51, 51);"><font face="微软雅黑" style="font-size: 12pt;">var b = 0xAF; //十六进制    175</font></span></div><div><span style="background-color: rgb(251, 250, 248); color: rgb(51, 51, 51);"><font face="微软雅黑" style="font-size: 12pt;">alert(a.toString(16));   //3a</font></span></div><div><span style="background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); line-height: 23px;"><font face="微软雅黑" style="font-size: 12pt;">将数字转换为指定的进制格式</font></span></div><div><br style="color: rgb(51, 51, 51);"/></div><div><span style="background-color: rgb(251, 250, 248); color: rgb(51, 51, 51);"><font face="微软雅黑" style="font-size: 12pt;">var str = &quot;3a&quot;;   </font></span></div><div><span style="background-color: rgb(251, 250, 248); color: rgb(51, 51, 51);"><font face="微软雅黑" style="font-size: 12pt;">parseInt(str, 16);   //第二个参数，指定字符串的进制形式，结果位58</font></span></div></div><div><br/></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(45, 79, 201);">你的电脑做着正确的二进制浮点运算，但问题是你输入的是十进制的数，电脑以二进制运算，这两者并不是总是转化那么好的，有时候会得到正确的结果，但有时候就不那么幸运了；</span></span></div><div style="text-align: left;"><div style="font-size: 12pt;"><br style="font-size: 12pt;"/></div></div><div style="text-align: left;"><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(45, 79, 201);">alert(0.7+0.1);  //输出0.7999999999999999</span></span></div><div style="text-align: left;"><div style="font-size: 12pt;"><br style="font-size: 12pt;"/></div></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(45, 79, 201);">alert(0.6+0.2);  //输出0.8；</span></span></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(227, 0, 0);">JS的小数运算有时候并不是那么精确，但是损失的精度一般也在可承受范围之内</span></span></div><div><br/></div><div><br/></div><div><span style="font-size: 18pt;">应用</span></div><div><br/></div><div><span style="font-size: 12pt;">1．计算两个文本框的和</span></div><div><span style="font-size: 12pt;">2．var k=0;  console.log(k++ + ++k +k +k++)</span></div><div><span style="font-size: 12pt;">3．掌握逻辑运算的意义</span></div><div><span style="font-size: 12pt;">4．掌握八进制、十六进制的写法</span></div><div><span style="font-size: 12pt;">5．掌握NaN的含义</span></div><div><span style="font-size: 12pt;">6．掌握Number函数的转换结果</span></div><div><span style="font-size: 12pt;">7．计算两个文本框的加减乘除</span></div><div><span style="font-size: 12pt;">要求：1) 使用Number方法类型转换</span></div><div><span style="font-size: 12pt;">          2) 计算结果保留三位小数</span></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div></span>
</div></body></html> 